package dapps.dao.proj;

import java.util.List;

import org.springframework.stereotype.Repository;
import org.springside.modules.orm.hibernate.HibernateDao;

import dapps.entity.proj.Proj;

//Spring DAO Bean的标识
@Repository
public class ProjDao extends HibernateDao<Proj, Long> {

	// 统一定义所有用户的HQL.
	private static final String QUERY_BY_ROLE_HQL = "select proj from Proj proj join proj.roles as role where role.name=?";

	public Proj loadByLoginName(String projName) {
		return findUniqueByProperty("loginName", projName);
	}

	/**
	 * 查找拥有指定角色的用户.
	 */
	public List<Proj> getProjsByRole(String roleName) {
		return find(QUERY_BY_ROLE_HQL, roleName);
	}
}
